package cn.xinfei.xdecision.common.utils.enums.enginex;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * 决策流版本状态枚举，与其他组件不同，多了一个"待审批"状态
 * Created by maying on 2023/03/02.
 **/
@Getter
@AllArgsConstructor
public enum EngineVersionStatusEnum {

	NEW(0,"新建"),
	ENABLE(1, "运行中"),
//	PENDING_APPROVAL(2, "待审批"),
	DISABLE(3, "已下线");

	private final Integer status;

	private final String name;


	public static EngineVersionStatusEnum get(Integer code) {
		if (Objects.isNull(code)) {
			return null;
		}
		for (EngineVersionStatusEnum e : EngineVersionStatusEnum.values()) {
			if (code.equals(e.getStatus())) {
				return e;
			}
		}
		return null;
	}

	public static String getName(Integer code) {
		EngineVersionStatusEnum engineVersionStatusEnum = get(code);
		return engineVersionStatusEnum == null ? "" : engineVersionStatusEnum.getName();
	}

}
